package com.ext.portlet.registration.action;

import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.liferay.portal.kernel.util.Constants;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.struts.PortletAction;

public class ViewRegistrationAction extends PortletAction {

	public ActionForward render(
			ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
			RenderRequest renderRequest, RenderResponse renderResponse)
		throws Exception {
		
		String forward = "";
		
		String cmd = ParamUtil.getString(renderRequest, Constants.CMD);
		
		if (cmd.equals("maintab")) {
			
			try{
				
				String tabs1 = ParamUtil.getString(renderRequest, "tabs1");				
				renderRequest.setAttribute("tabs1",tabs1);
				forward = "portlet.ext.registration.blossomlist";				
				
			}catch(Exception e){
				
			}			
		}
		
		if(cmd.equals("subtab")){
			
			try {
				
				String tabs1 = ParamUtil.getString(renderRequest, "tabs1");
				String tabs2 = ParamUtil.getString(renderRequest, "tabs2");
				
				renderRequest.setAttribute("tabs1",tabs1);
				renderRequest.setAttribute("tabs2",tabs2);
				
				forward = "portlet.ext.registration.blossomlist";
				//return mapping.findForward("portlet.ext.registration.blossomlist");
				
			}catch(Exception e){				
				System.out.println("<<<<<<<Error>>>>>>>>");				
			}
			
		}	
		
		if (cmd.equals("campus-maintab")) {
			
			try{
				
				String tabs1 = ParamUtil.getString(renderRequest, "tabs1");				
				renderRequest.setAttribute("tabs1",tabs1);
				forward = "portlet.ext.registration.campus.campusList";				
				
			}catch(Exception e){
				
			}			
		}
		
		if(cmd.equals("campus-subtab")){
			
			try {
				
				String tabs1 = ParamUtil.getString(renderRequest, "tabs1");
				String tabs2 = ParamUtil.getString(renderRequest, "tabs2");
				
				renderRequest.setAttribute("tabs1",tabs1);
				renderRequest.setAttribute("tabs2",tabs2);
				
				forward = "portlet.ext.registration.campus.campusList";
				//return mapping.findForward("portlet.ext.registration.blossomlist");
				
			}catch(Exception e){				
				System.out.println("<<<<<<<Error>>>>>>>>");				
			}
			
		}	
		
		if(cmd.equals("mainstay-tab")){
			
			String tabs1 = ParamUtil.getString(renderRequest, "tabs1");				
			renderRequest.setAttribute("tabs1",tabs1);
			forward = "portlet.ext.registration.mainstay.mainstayList";
					
		}
		
		return mapping.findForward(forward);
	}
}
